﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using RuleCode.Table;

namespace map.lvyouguanli
{
    public partial class WebForm3 : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            GridViewBind();

        }
        

        private void GridViewBind()
        {
            lyjingdian x = lyjingdian.Find("cbuserid = '" + AliApi.appUserId + " '");
            this.GridView1.DataSource = x.MyTable;
            this.GridView1.DataBind();
        }

        protected void Button1_Click(object sender, EventArgs e)
        {

            lyjingdian zk = lyjingdian.Find(" 1=2 ");
            zk.New();
            zk.userid = AliApi.appUserId;
            zk.Name = Name.Text;
            zk.Description = Description.Value;
            zk.Transport = Transport.Value;
            zk.Insert();
            GridViewBind();



        }
        protected void Button2_Click(object sender, EventArgs e)
        {
            lyjingdian zk = lyjingdian.Find(" recid ='" + Label_recid.Text + "'", "RECID");

            zk.Name = Name.Text;
            zk.Description = Description.Value;
            zk.Transport = Transport.Value;
            zk.Modify();
            GridViewBind();
        }
        protected void GridView1_SelectedIndexChanged(object sender, EventArgs e)
        {
        }

        protected void GridView1_SelectedIndexChanging(object sender, GridViewSelectEventArgs e)
        {

            lyjingdian z = new lyjingdian();
            string id = GridView1.DataKeys[e.NewSelectedIndex].Value.ToString();
            lyjingdian uc = lyjingdian.Find(" recid = '" + id + "'", "RECID");

            Label_recid.Text = uc.RECID.ToString();
            Name.Text = uc.Name.StringValue;
            Description.Value = Server.HtmlEncode(uc.Description.StringValue);
            Transport.Value = Server.HtmlEncode(uc.Transport.StringValue);
         
        }

        protected void GridView1_RowDeleted(object sender, GridViewDeletedEventArgs e)
        {

        }

        protected void GridView1_RowDeleting(object sender, GridViewDeleteEventArgs e)
        {
            string id = GridView1.DataKeys[e.RowIndex].Value.ToString();
            lyjingdian uc = lyjingdian.Find(" recid = '" + id + "'", "RECID");
            uc.Delete();
            GridViewBind();

        }
    }
}
